<?php include '../public/header.php' ?>
<?php include '../public/header_public.php' ?>
<style>
    .bkuai{width: 140px;height: 150px;margin-right: 20px;float: left;cursor: pointer;position: relative;border-radius: 5px}
    .bkuai:hover{background-color: #eee;}
    .bkuai:hover .opts{display:block}
    .bkuai img{margin: 10px 30px 0}
    .bkuai .baotit{padding: 0 5px;line-height: 18px;text-align: center;
        display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 3;overflow: hidden;
    }
    .bkuai .opts{position: absolute;right: 0;top: 6px;font-size: 14px;color: #0E0EFF;width: 30px;height: 30px;display: none;}
    .bkuai .optlist{position: absolute;right: 13px;top: 25px;background-color: #FFFFFF;border: 1px solid #eeeeee;
        border-radius: 3px;padding: 5px 0;z-index: 99;
    }
    .bkuai .optlist div{margin-top: 5px;padding: 0 20px}
    .bkuai .optlist div:hover{color: #0E0EFF;}
    #kongjia{text-align: center;color: #bbb;margin-top: 100px;}
    #gofan{position: absolute;left: 0;top: 1px;font-weight: bold;color: red;cursor: pointer;font-size: 18px;padding: 2px 4px}

    .banlan{width: 700px;height: 630px;margin: 0 auto;}
    .banlan .lankuai{width: 100%;height: 100%;text-align: center}
    .banlan .lankuai{height: 100%;}
    .banlanbut{position: absolute;right: 50px;top: 35px;background-color: #f4f4f4;color: #575757;border: 1px solid #aaa}
    .banlanbut:hover{background-color: #0079fe;color: #FFFFFF;border: 1px solid #0079fe}
</style>
<body class="laytp-container">
<div style="height: 45px"></div>
<div id="opt_nav">
</div>
<div id="dialog">
    <div class="page-title" id="page-title">
        <div class="page-title-con">
            <span class="title">文件资料库-查询</span>
            <div class="move_title"></div>
            <div class="page-title-opt-list">
                <span id="page-close" class="page-close" onclick="layer_close()">×</span>
            </div>
        </div>
    </div>
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">文件名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" id="name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">上传人</label>
                        <div class="layui-input-block">
                            <input type="text" name="created_user_name" id="created_user_name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">上传时间</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="created_at" id="created_at" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <input type="hidden" id="muid" name="muid">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" onclick="TableSearchFunc()" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableResetFunc()" type="button" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <?php include 'tan_wen.php' ?>
            <div class="layui-col-md9" id="table_list">
                <div class="layui-card-body" style="padding:10px">
                    <div class="lanquanbu layui-hide">
                        <span class="lanbanobj layui-hide"></span>
                        <div id="mubanname"></div>
                        <div class="banlan">
                            <div class="lankuai lan_img"><img id="nanimgs" src="" style="height: 100%"></div>
                            <div class="lankuai layui-hide lan_pdf"><iframe src="" frameborder="0" width="100%" height="100%"></iframe></div>
                            <div class="lankuai layui-hide lan_doc"><iframe src="" frameborder="0" width="100%" height="100%"></iframe></div>
                            <div class="lankuai layui-hide lan_video">
                                <video controls autoplay style="width: 100%;height: 100%">
                                    <source src="" type="video/mp4">
                                </video>
                            </div>
                            <div class="lankuai lan_nolan"><img src="/static/admin/images/nolan.png" style="margin-top: 100px;"></div>
                        </div>
                        <button class="layui-btn layui-btn-sm banlanbut">操 作</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    var param_name = $('#name', parent.document).val() || '';
    var param_created_user_name = $('#created_user_name', parent.document).val() || '';
    var param_created_at = $('#created_at', parent.document).val() || '';
    $('#name').val(param_name)
    $('#created_user_name').val(param_created_user_name)
    $('#created_at').val(param_created_at)

    TableSearchFunc();

    function TableSearchFunc() {
        var name = $("#name").val() || '';
        var created_user_name = $("#created_user_name").val() || '';
        var created_at = $("#created_at").val() || '';
        if(!name && !created_user_name && !created_at){
            facade.error('请输入搜索内容');return false;
        }

        setWenList();
    }



    var param_enginid = parent.param_enginid;
    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;


        dropdown.render({
            elem: '.banlanbut'
            ,data: [
                {title: '详细信息',id: 'show'},
                {title: '下载',id: 'down'},
                {title: '编辑',id: 'edit'},
                {title: '删除',id: 'delete'},
            ]
            ,click: function(data, othis){
                var funcname = data.id;
                var bandata = JSON.parse($(".lanbanobj").text());

                if(bandata.type == 'ban'){
                    if(funcname == 'show'){
                        openPageEdit('showmu.php?close=1&id='+bandata.id);
                    }
                    if(funcname == 'edit'){
                        openPageEdit('edit_ban.php?close=1&id='+bandata.id);
                    }
                    if(funcname == 'down'){
                        public_down_ban_file(bandata.encpath)
                    }
                    if(funcname == 'delete'){
                        delete_temp_cur(ask_engin_mu_del, {id:bandata.id}, bandata.pid);
                    }
                }else{
                    if(funcname == 'show'){
                        openPageEdit('../engin_bao/show.php?close=1&id='+bandata.id);
                    }
                    if(funcname == 'edit'){
                        openPageEdit('../engin_bao/edittwo.php?close=1&muid='+bandata.pid+'&id='+bandata.id);
                    }
                    if(funcname == 'down'){
                        public_down_bao_file(bandata.encpath)
                    }
                    if(funcname == 'delete'){
                        delete_temp_cur(ask_engin_bao_del, {id:bandata.id}, bandata.pid);
                    }
                }
            }
        });


    });






    function setYulanMuban(data) {


        $("#mubanid").val(data.id).attr('datatype',data.type);
        $("#mubanname").html('/ '+data.parentsName);
        $(".lanquanbu").removeClass('layui-hide');


        $(".lanbanobj").text(JSON.stringify(data));

        $(".lankuai").addClass('layui-hide');
        var ext = data.ext;
        var encpath = data.encpath;

        $(".lan_img").find('img').attr('src', '');
        $(".lan_pdf").find('iframe').attr('src', '');
        $(".lan_doc").find('iframe').attr('src', '');
        $(".lan_video").find('video').attr('src', '');


        if(data.type == 'ban'){
            var setUrl = get_ban_file_complete(encpath);
        }else{
            var setUrl = get_bao_file_complete(encpath);
        }





        if(ext == 'png' || ext == 'pneg' || ext == 'jpg' || ext == 'jpeg' || ext == 'gif'){
            $(".lan_img").removeClass('layui-hide');
            var imgElement = document.getElementById('nanimgs');
            imgElement.src = setUrl
            imgElement.src = imgElement.src + '?timestamp=' + new Date().getTime();
        }else if(ext == 'pdf'){
            $(".lan_pdf").removeClass('layui-hide');
            $(".lan_pdf").find('iframe').attr('src', setUrl);
        }else if(ext == 'doc' || ext == 'docx' || ext == 'xls' || ext == 'xlsx' || ext == 'ppt' || ext == 'pptx'){
            layui.use(['laytp'], function() {
                $.ajax({
                    url:get_ban_file_complete(encpath),
                    type:'get',
                    data:{token:facade.getCookie('token')},
                    dataType:'json',
                    async: false,
                    success:function (e) {
                        if(e.code == 2000){
                            var urls = "https://view.officeapps.live.com/op/view.aspx?src="+encodeURI(server_doc_name+e.data);
                            $(".lan_doc").removeClass('layui-hide');
                            $(".lan_doc").find('iframe').attr('src', urls);
                        }
                    }
                });
            });
        }else if(ext == 'mp4'){
            layui.use(['laytp'], function() {
                $.ajax({
                    url:get_ban_file_complete(encpath),
                    type:'get',
                    data:{token:facade.getCookie('token')},
                    dataType:'json',
                    async: false,
                    success:function (e) {
                        if(e.code == 2000){
                            $(".lan_video").removeClass('layui-hide');
                            $(".lan_video").find('video').attr('src', server_doc_name+e.data);
                        }
                    }
                });
            });
        }else{
            $(".lan_nolan").removeClass('layui-hide');
        }



    }
    function close_right_lanban(){
        $("#mubanid").val('');
        $("#mubanname").html('');
        $(".lanquanbu").addClass('layui-hide');
    }





























    function auth_but_func_downjia(muid){
        facade.ajax({url: ask_engin_mu_down, data: {muid:muid,enginid:param_enginid}}).done(function(res){
            if (res.code === 2000) {
                down_file(res.data);
            }
        });
    }

    function listTableResetFunc() {
        var name = $("#name").val('');
        var created_user_name = $("#created_user_name").val('');
        var created_at = $("#created_at").val('');

        var muid = $("#muid").val();
        get_jia_info(muid)
    }






    function delete_temp_cur(url, data, pid){
        layer.confirm("<div class='tit'>是否确认删除？</div><div class='exp'>删除后不可恢复，请谨慎删除</div>", {
                title:'操作确认',
                icon: 3,
                area:['450px','220px'],
                btn:['确定']
            }, function(conindex){
                facade.ajax({url: url, data:data}).done(function(res){
                    if (res.code === 2000) {
                        facade.success("提交成功!");
                        setTimeout(() => {
                            setWenList()
                            layer.close(conindex);
                        }, 1500);
                    }else{
                        layer.close(conindex);
                    }
                });
            }
        )
    }







    function layer_close(){
        try {
            parent.get_mu_info();
        }catch (e) {

        }
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }
</script>
</body>
</html>
